<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=1.0, minimum-scale=1.0, maximum-scale=1.0" />
	<title>工单详情</title>
	<link rel="stylesheet" type="text/css" href="common.css">
</head>
<body class="grabcss">
	<div>
		<div class="ordernum" id="job_id"></div>
			<a href="order.html">
				<div class="return">
					<img src="image/2.png">
					返回
				</div>
			</a>
		<div class="clearfix"></div>
	</div>
	<div style="margin-top: 0.08rem;border-bottom: 1px solid #d6d6d6;padding-bottom: 0.1rem;line-height: 0.22rem;">
		<div class="olab">
			<label id="create_name"></label>
			<label id="create_time"></label>
		</div>
		<div class="olab">
			<label id="create_phone"></label>
			<label id="job_time"></label>
		</div>
	</div>

	<div class="grabbox">
		<h1>工单地址：</h1>
		<div class="content" id="position"></div>
		<h1>工单问题：</h1>
		<div class="content" id="problem"></div>
		<h1>工单详情：</h1>
		<div class="content" id="details"></div>
	</div>
	
	<div style="position: fixed;width: 100%;height: 0.52rem;background-color: #03a9f4;text-align: center;line-height: 0.52rem;bottom: 0;font-size: 0.16rem;color: #fff" class="done">
		点击完成
	</div>
	<script src="js/jquery-1.8.3.min.js"></script>
	<script src="js/common.js"></script>
	<script type="text/javascript">
	function getUrlParms(name){
		   var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
		   var r = window.location.search.substr(1).match(reg);
		   if(r!=null)
		   return decodeURIComponent(r[2]);
		   return null;
		   }
		
		
		var job_id = getUrlParms("id");
		console.log(job_id)
		$.ajax({
			type:"POST",
			url:"../Job/getJobById",
			data:{job_id:job_id},
			dataType:"Json",
			success:function(res){
				console.log(res)
				if(res.info=="success"){
					var data=res.object;
					$("#job_id").html("工单："+data.job_id);
					$("#create_name").html("创建人："+data.create_name);
					$("#create_time").html("创建时间："+data.create_time);
					$("#create_phone").html("创建人电话："+data.create_phone);
					$("#job_time").html("工时："+data.standard_time);
					$("#position").html(data.position);
					$("#problem").html(data.problem);
					$("#details").html(data.detail);
				}
			}
		})
		
		$("body").click(function(event) {
			if($(event.target).hasClass("done")){
				var jobId = $("#job_id").html();
				var job_id=jobId.substring(3,21);
				console.log(job_id)
				$.ajax({
		   			type:"POST",
		   			url:"../Job/finishJob",
		   			data:{job_id:job_id},
		   			dataType:"Json",
		   			success:function(res){
		   				var info = res.info;
		   				console.log(res)
		   				if(info=="success"){
		   					window.location.href="order.html";
		   				}else{
		   					
		   				}
		   			}
		   		})
			}
		})
	</script>
</body>
</html>